<?
$sbo_hotel_price 		= 0;
$txt_hotel_name			= "";
$sbo_hotel_country		= 0;
$sbo_hotel_location		= 0;
$txt_hotel_star			= 0;

if (isset($_SESSION['hotel_search_fields']))
{
	$hotel_search_fields 	= $_SESSION['hotel_search_fields'];
	$sbo_hotel_price 		= $hotel_search_fields['hotel_price'];
	$txt_hotel_name			= $hotel_search_fields['hotel_name'];
	$sbo_hotel_country		= $hotel_search_fields['hotel_country'];
	$sbo_hotel_location		= $hotel_search_fields['hotel_location'];
	$txt_hotel_star			= $hotel_search_fields['hotel_star'];
}
?>
<form action='/khach-san-tim-kiem/du-lich-da-nang.html' method="post" id='frmSearchHotel'>
	<input type='hidden' name='func' value='search'>
    <table cellpadding="0" cellspacing="0" width="400" border="0" class='tbl_transform tbl_search'>
    	<tr>
        	<td width='60'>
            	<div class='search_lbl'>Tên</div>
            </td>
            <td colspan="3">
            	<input type='text' class='txt_book' style='width:305px;' name='txt_hotel_name' id='txt_hotel_name' value='<?=$txt_hotel_name?>' />
            </td>
        </tr>
        <tr>
        	<td width='60'>
            	<div class='search_lbl'>Quốc gia</div>
            </td>
            <td>
            	<select name='sbo_hotel_country' id='sbo_hotel_country' style='width:110px' onchange='reload_location(this.value,"td_hotel_location","sbo_hotel_location")'>
                	<option value='0'>Tùy chọn</option>
                <?
					$countryFirst = NULL;
					$countries = Country::getAllCountries();
					foreach($countries as $country)
					{
						if (!$countryFirst) 
							$countryFirst = $country;
					?>
                    <option value='<?=$country->getid()?>' <?=($sbo_hotel_country==$country->getid())?"selected='selected'":""?>><?=$country->getname()?></option>
                    <?
					}
				?>
                </select>
            </td>
            <td width='60'>
            	<div class='search_lbl'>Địa điểm</div>
            </td>
            <td id='td_hotel_location'>
            	<?
				$locations = $countryFirst->getAllLocations();
				if (sizeof($locations) > 0)
				{
				?>
					<select name='sbo_hotel_location' id='sbo_hotel_location'>
                    	<option value='0'>Tùy chọn</option>
					<?
						foreach ($locations as $location)
						{
						?>
							<option value='<?=$location->getid()?>' <?=($sbo_hotel_location == $location->getid())?"selected='selected'":""?>><?=$location->getname()?></option>
						<?
						}
					?>
					</select>
				<?
				}
				?>
            </td>
        </tr>
        
        <tr>
			<td width="50">
                <div class='search_lbl'>Giá</div>
            </td>
            <td>
                <select name='sbo_hotel_price' id='sbo_hotel_price'  style='width:110px'>
                	<option value='0' <?=($sbo_hotel_price == 0)?"selected='selected'":""?>>Tùy chọn</option>
                    <?
					$prices = PriceSection::getAllPriceSections();
					foreach ($prices as $price)
					{
					?>
                    <option value="<?=$price->getid()?>" <?=($sbo_hotel_price == $price->getid())?"selected='selected'":""?>><?=$price->getname()?></option>
                    <?
					}
					?>
                </select>
            </td>
            <td width='50'>
            	<div class='search_lbl'>Hạng</div>
            </td>
            <td>
                <div class='rating'>
                    <div class='star_no <?=($txt_hotel_star>=1)?"active":""?>' rel='1'></div>
                    <div class='star_no <?=($txt_hotel_star>=2)?"active":""?>' rel='2'></div>
                    <div class='star_no <?=($txt_hotel_star>=3)?"active":""?>' rel='3'></div>
                    <div class='star_no <?=($txt_hotel_star>=4)?"active":""?>' rel='4'></div>
                    <div class='star_no <?=($txt_hotel_star>=5)?"active":""?>' rel='5'></div>
                </div>
                <input type='hidden' name='txt_hotel_star' value='<?=$txt_hotel_star?>' />                
            </td>
        </tr>
			
        <tr>
            <td></td>
            <td></td>
            <td></td>
            <td>
                <input type='submit' value='Tìm kiếm' class='search_btn' />
            </td>
        </tr>
    </table>
</form>
<script>
	$(document).ready(function()
	{
		$("#frmSearchHotel .star_no").click(function()
		{
			$("#frmSearchHotel .star_no").removeClass('active');
			var rel = $(this).attr('rel');
			for (i=1;i<=rel;i++)
			{
				$("#frmSearchHotel .star_no[rel="+i+"]").addClass('active');
			}
			$("#frmSearchHotel .txt_hotel_star").val(rel);
		});
		
		$("#frmSearchHotel .star_no").hover(function()
		{
			var this_star = $(this);
			while (this_star.hasClass('star_no'))
			{
				this_star.addClass('hov');
				this_star = this_star.prev();
			}
		},function()
		{
			$(".star_no").removeClass('hov');
		});
	});
</script>